<include file="../header" />
<body class="J_scroll_fixed">
    <script type="text/javascript" src="__ROOT__/statics/js/ajaxfileupload.js"></script>
    <script type="text/javascript" src="__ROOT__/statics/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__ROOT__/statics/js/ueditor/ueditor.all.min.js"></script>

    <script type="text/javascript">
        $(function () {

            $("button#send").click(function() {

                //$("input[name=expirence]").val(expirence.getContent());
                $("input[name=goodAt]").val(goodAt.getContent());

                $("input[name=categoryIds]").val('');
                $("input[name=category]").each(function() {

                    if($(this).is(":checked")) {
                        $("input[name=categoryIds]").val($("input[name=categoryIds]").val() + $(this).val() + ",");
                    }

                });

                $("input[name=categoryIds]").val($("input[name=categoryIds]").val().substring(0, $("input[name=categoryIds]").val().length-1));

                if($("input[name=categoryIds]").val() == "") {
                    alert("请选择病症");
                    return false;
                }

                $("form").submit();

            });

            var goodAt = UE.getEditor('goodAt',{
                initialFrameHeight:300,
                initialContent : "",
                serverUrl :'{:U("activity/ueditorUpload")}'
            });

//            var expirence = UE.getEditor('expirence',{
//                initialFrameHeight:300,
//                initialContent : "",
//                serverUrl :'{:U("activity/ueditorUpload")}'
//            });

            $("button#upload").click(function(){
                //上传文件
                $.ajaxFileUpload({
                    url:"{:U('Customer/uploadImage')}",//处理图片脚本
                    secureuri :false,
                    fileElementId :'fileToUpload',//file控件id
                    dataType : 'json',
                    success : function (data, status){
                        $("input[name=imageUrl]").val(data);
                        $("img[name=preImage]").attr("src", data);
                    },
                    error: function(data, status, e){
                        alert(e);
                    }
                })
            });

        });
    </script>
    <div class="wrap jj">

        <div class="common-form">
            <form method="post" class="form-horizontal J_ajaxForm" action="{:U('customer/addDoctor')}">
                <fieldset>
                    <input type="hidden" name='categoryIds' value='' />
                    <input type="hidden" name='customerId' value='{$info.customer_id}' />

                    <div class="control-group">
                        <label class="control-label">医生名称:</label>
                        <div class="controls">
                            <input type="text" class="input" name="doctorName" value="{$info.nickname}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">简介:</label>
                        <div class="controls">
                            <textarea name="brief"></textarea>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">医院名称:</label>
                        <div class="controls">
                            <input type="text" class="input" name="hospitalName" value="{$info.hospital_name}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">内容描述：</label>
                        <div class="controls">
                            <input type="hidden" name="goodAt" />
                            <script type="text/plain" id="goodAt" name="goodAt">{$info.goodAt}</script>
                        </div>
                    </div>
                    <!--<div class="control-group">-->
                        <!--<label class="control-label">职业经历：</label>-->
                        <!--<div class="controls">-->
                            <!--<input type="hidden" name="expirence" />-->
                            <!--<script type="text/plain" id="expirence" name="expirence">{$info.expirence}</script>-->
                        <!--</div>-->
                    <!--</div>-->
                    <div class="control-group">
                        <label class="control-label">医生通道地址:</label>
                        <div class="controls">
                            <input type="text" class="input" name="doctorLink" value="{$info.doctor_link}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">头像预览</label>
                        <div class="controls">
                            <img src="{$info.headimgurl}" name="preImage" style="width:224px;height:168.5px;" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">上传头像</label>
                        <div class="controls">
                            <input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
                            <button class="btn" type="button" id="upload">上传</button>
                            <input type="hidden" name="imageUrl" value="{$info.headimgurl}" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">城市:</label>
                        <div class="controls">
                            <select name="cityId">
                                {:getCitySelectOptionHtml(0, 0)}
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">病症：</label>
                        <div class="controls">
                            <foreach name="categoryList" item="ck" key="k">
                                <label class="checkbox inline">
                                    <input type="checkbox" id="inlineCheckbox1" name='category' value="{$ck.category_id}"> {$ck.category_name}
                                </label>
                            </foreach>
                        </div>
                    </div>

                </fieldset>

                <div class="form-actions">
                    <button id="send" type="button" class="btn btn-primary">添加</button>
                    <a class="btn" href="__URL__">返回</a>
                </div>
            </form>
        </div>
    </div>
    <script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>